Electronic locks use an electrical servomechanism to reversibly block locking or unlocking. In some locks, the plunger of the solenoid functions as the bolt or latch of the lock. In other locks, the plunger is configured to reversibly prevent the movement of a separate bolt or latch. In either case, the plunger performs a linear movement or rotation under the influence of electromagnetic forces and elastic elements.